package com.itasura.method.invocation;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author sailor wang
 * @date 2018/9/1 下午1:00
 * @description
 */
public class ThreadAsyncExecutor implements AsyncExecutor{

    private final AtomicInteger idx = new AtomicInteger(0);


    /**
     * 开始执行异步任务，直接返回结果
     *
     * @param task
     * @return
     */
    @Override
    public <T> AsyncResult<T> startProcess(Callable<T> task) {
        return startProcess(task,null);
    }

    /**
     * 开始执行异步任务，返回直接结果，执行回调当任务完成
     *
     * @param task
     * @param callback
     * @return
     */
    @Override
    public <T> AsyncResult<T> startProcess(Callable<T> task, AsyncCallback<T> callback) {
        return null;
    }

    /**
     * 结束异步任务的处理。如果需要，阻止当前线程并返回完成任务的值
     *
     * @param asyncResult
     * @return
     * @throws ExecutionException
     * @throws InterruptedException
     */
    @Override
    public <T> T endProcess(AsyncResult<T> asyncResult) throws ExecutionException, InterruptedException {
        return null;
    }
}